package com.cskaoyan.mall.user.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cskaoyan.mall.user.converter.UserAddressConverter;
import com.cskaoyan.mall.user.dto.UserAddressDTO;
import com.cskaoyan.mall.user.mapper.UserAddressMapper;
import com.cskaoyan.mall.user.model.UserAddress;
import com.cskaoyan.mall.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserAddressServiceImpl implements UserAddressService {
    @Autowired
    UserAddressMapper userAddressMapper;
    @Autowired
    UserAddressConverter userAddressConverter;
    @Override
    public List<UserAddressDTO> findUserAddressListByUserId(String userId) {
        LambdaQueryWrapper<UserAddress> userAddressLambdaQueryWrapper = new LambdaQueryWrapper<>();

        userAddressLambdaQueryWrapper.eq(UserAddress::getUserId,userId);
        List<UserAddress> userAddresses = userAddressMapper.selectList(userAddressLambdaQueryWrapper);
        List<UserAddressDTO> userAddressDTOS = userAddressConverter.userAddressPOs2DTOs(userAddresses);

        return userAddressDTOS;
    }
}
